package com.platform.modules.sys.service.impl;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.platform.common.utils.Query;
import com.platform.modules.sys.dao.SysLogDao;
import com.platform.modules.sys.entity.SysLogEntity;
import com.platform.modules.sys.service.SysLogService;

/**
 * @author 肖亮
 */
@Service("sysLogService")
public class SysLogServiceImpl extends ServiceImpl<SysLogDao, SysLogEntity> implements SysLogService {

	@Override
	public IPage queryPage(Map<String, Object> params) {
		String key = (String) params.get("key");

		Page<SysLogEntity> page = new Query<SysLogEntity>(params).getPage();

		return baseMapper.selectPage(page,
				new QueryWrapper<SysLogEntity>().like(StringUtils.isNotBlank(key), "USER_NAME", key).or()
						.like(StringUtils.isNotBlank(key), "OPERATION", key).orderByDesc("CREATE_TIME"));
	}

	  @Override
	    public boolean removeByIds(Collection<? extends Serializable> idList) {
	        return SqlHelper.delBool(baseMapper.deleteBatchIds(idList));
	    }
	
	
	@Override
	public boolean deleteBatch(String[] ids) {
		// TODO Auto-generated method stub
		return this.removeByIds(Arrays.asList(ids));
	}
}
